package com.chartboost.sdk.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

abstract class ba<K, V, M extends Map<K, V>>
  implements Serializable, ConcurrentMap<K, V>
{
  private volatile M a = (Map)bb.a("delegate", a((Map)bb.a("map", paramN)));
  private final transient Lock b = new ReentrantLock();
  private final h<K, V> c;

  protected <N extends Map<? extends K, ? extends V>> ba(N paramN, ba.h.a parama)
  {
    this.c = ((ba.h.a)bb.a("viewType", parama)).a(this);
  }

  private boolean a(Object paramObject1, Object paramObject2)
  {
    if (paramObject1 == null)
      return paramObject2 == null;
    return paramObject1.equals(paramObject2);
  }

  protected M a()
  {
    this.b.lock();
    try
    {
      Map localMap = a(this.a);
      return localMap;
    }
    finally
    {
      this.b.unlock();
    }
  }

  abstract <N extends Map<? extends K, ? extends V>> M a(N paramN);

  protected void b(M paramM)
  {
    this.a = paramM;
  }

  public final void clear()
  {
    this.b.lock();
    try
    {
      b(a(Collections.emptyMap()));
      return;
    }
    finally
    {
      this.b.unlock();
    }
  }

  public final boolean containsKey(Object paramObject)
  {
    return this.a.containsKey(paramObject);
  }

  public final boolean containsValue(Object paramObject)
  {
    return this.a.containsValue(paramObject);
  }

  public final Set<Map.Entry<K, V>> entrySet()
  {
    return this.c.b();
  }

  public final boolean equals(Object paramObject)
  {
    return this.a.equals(paramObject);
  }

  public final V get(Object paramObject)
  {
    return this.a.get(paramObject);
  }

  public final int hashCode()
  {
    return this.a.hashCode();
  }

  public final boolean isEmpty()
  {
    return this.a.isEmpty();
  }

  public final Set<K> keySet()
  {
    return this.c.a();
  }

  public final V put(K paramK, V paramV)
  {
    this.b.lock();
    try
    {
      Map localMap = a();
      try
      {
        Object localObject3 = localMap.put(paramK, paramV);
        b(localMap);
        return localObject3;
      }
      finally
      {
        b(localMap);
      }
    }
    finally
    {
      this.b.unlock();
    }
  }

  public final void putAll(Map<? extends K, ? extends V> paramMap)
  {
    this.b.lock();
    try
    {
      Map localMap = a();
      localMap.putAll(paramMap);
      b(localMap);
      return;
    }
    finally
    {
      this.b.unlock();
    }
  }

  public V putIfAbsent(K paramK, V paramV)
  {
    this.b.lock();
    try
    {
      if (!this.a.containsKey(paramK))
      {
        Map localMap = a();
        try
        {
          Object localObject4 = localMap.put(paramK, paramV);
          b(localMap);
          return localObject4;
        }
        finally
        {
          b(localMap);
        }
      }
    }
    finally
    {
      this.b.unlock();
    }
    Object localObject2 = this.a.get(paramK);
    this.b.unlock();
    return localObject2;
  }

  public final V remove(Object paramObject)
  {
    this.b.lock();
    try
    {
      boolean bool = this.a.containsKey(paramObject);
      if (!bool)
        return null;
      Map localMap = a();
      try
      {
        Object localObject3 = localMap.remove(paramObject);
        b(localMap);
        return localObject3;
      }
      finally
      {
        b(localMap);
      }
    }
    finally
    {
      this.b.unlock();
    }
  }

  public boolean remove(Object paramObject1, Object paramObject2)
  {
    this.b.lock();
    try
    {
      if ((this.a.containsKey(paramObject1)) && (a(paramObject2, this.a.get(paramObject1))))
      {
        Map localMap = a();
        localMap.remove(paramObject1);
        b(localMap);
        return true;
      }
      return false;
    }
    finally
    {
      this.b.unlock();
    }
  }

  public V replace(K paramK, V paramV)
  {
    this.b.lock();
    try
    {
      boolean bool = this.a.containsKey(paramK);
      if (!bool)
        return null;
      Map localMap = a();
      try
      {
        Object localObject3 = localMap.put(paramK, paramV);
        b(localMap);
        return localObject3;
      }
      finally
      {
        b(localMap);
      }
    }
    finally
    {
      this.b.unlock();
    }
  }

  public boolean replace(K paramK, V paramV1, V paramV2)
  {
    this.b.lock();
    try
    {
      if (this.a.containsKey(paramK))
      {
        boolean bool = a(paramV1, this.a.get(paramK));
        if (bool);
      }
      else
      {
        return false;
      }
      Map localMap = a();
      localMap.put(paramK, paramV2);
      b(localMap);
      return true;
    }
    finally
    {
      this.b.unlock();
    }
  }

  public final int size()
  {
    return this.a.size();
  }

  public String toString()
  {
    return this.a.toString();
  }

  public final Collection<V> values()
  {
    return this.c.c();
  }

  protected static abstract class a<E>
    implements Collection<E>
  {
    abstract Collection<E> a();

    public final boolean add(E paramE)
    {
      throw new UnsupportedOperationException();
    }

    public final boolean addAll(Collection<? extends E> paramCollection)
    {
      throw new UnsupportedOperationException();
    }

    public final boolean contains(Object paramObject)
    {
      return a().contains(paramObject);
    }

    public final boolean containsAll(Collection<?> paramCollection)
    {
      return a().containsAll(paramCollection);
    }

    public boolean equals(Object paramObject)
    {
      return a().equals(paramObject);
    }

    public int hashCode()
    {
      return a().hashCode();
    }

    public final boolean isEmpty()
    {
      return a().isEmpty();
    }

    public final Iterator<E> iterator()
    {
      return new ba.f(a().iterator());
    }

    public final int size()
    {
      return a().size();
    }

    public final Object[] toArray()
    {
      return a().toArray();
    }

    public final <T> T[] toArray(T[] paramArrayOfT)
    {
      return a().toArray(paramArrayOfT);
    }

    public String toString()
    {
      return a().toString();
    }
  }

  private class b extends ba.a<Map.Entry<K, V>>
    implements Set<Map.Entry<K, V>>
  {
    private b()
    {
    }

    Collection<Map.Entry<K, V>> a()
    {
      return ba.a(ba.this).entrySet();
    }

    public void clear()
    {
      ba.b(ba.this).lock();
      try
      {
        Map localMap = ba.this.a();
        localMap.entrySet().clear();
        ba.this.b(localMap);
        return;
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }

    public boolean remove(Object paramObject)
    {
      ba.b(ba.this).lock();
      try
      {
        boolean bool1 = contains(paramObject);
        if (!bool1)
          return false;
        Map localMap = ba.this.a();
        try
        {
          boolean bool2 = localMap.entrySet().remove(paramObject);
          ba.this.b(localMap);
          return bool2;
        }
        finally
        {
          ba.this.b(localMap);
        }
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }

    public boolean removeAll(Collection<?> paramCollection)
    {
      ba.b(ba.this).lock();
      try
      {
        Map localMap = ba.this.a();
        try
        {
          boolean bool = localMap.entrySet().removeAll(paramCollection);
          ba.this.b(localMap);
          return bool;
        }
        finally
        {
          ba.this.b(localMap);
        }
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }

    public boolean retainAll(Collection<?> paramCollection)
    {
      ba.b(ba.this).lock();
      try
      {
        Map localMap = ba.this.a();
        try
        {
          boolean bool = localMap.entrySet().retainAll(paramCollection);
          ba.this.b(localMap);
          return bool;
        }
        finally
        {
          ba.this.b(localMap);
        }
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }
  }

  final class c extends ba.h<K, V>
    implements Serializable
  {
    c()
    {
    }

    public Set<K> a()
    {
      return Collections.unmodifiableSet(ba.a(ba.this).keySet());
    }

    public Set<Map.Entry<K, V>> b()
    {
      return Collections.unmodifiableSet(ba.a(ba.this).entrySet());
    }

    public Collection<V> c()
    {
      return Collections.unmodifiableCollection(ba.a(ba.this).values());
    }
  }

  private class d extends ba.a<K>
    implements Set<K>
  {
    private d()
    {
    }

    Collection<K> a()
    {
      return ba.a(ba.this).keySet();
    }

    public void clear()
    {
      ba.b(ba.this).lock();
      try
      {
        Map localMap = ba.this.a();
        localMap.keySet().clear();
        ba.this.b(localMap);
        return;
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }

    public boolean remove(Object paramObject)
    {
      return ba.this.remove(paramObject) != null;
    }

    public boolean removeAll(Collection<?> paramCollection)
    {
      ba.b(ba.this).lock();
      try
      {
        Map localMap = ba.this.a();
        try
        {
          boolean bool = localMap.keySet().removeAll(paramCollection);
          ba.this.b(localMap);
          return bool;
        }
        finally
        {
          ba.this.b(localMap);
        }
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }

    public boolean retainAll(Collection<?> paramCollection)
    {
      ba.b(ba.this).lock();
      try
      {
        Map localMap = ba.this.a();
        try
        {
          boolean bool = localMap.keySet().retainAll(paramCollection);
          ba.this.b(localMap);
          return bool;
        }
        finally
        {
          ba.this.b(localMap);
        }
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }
  }

  final class e extends ba.h<K, V>
    implements Serializable
  {
    private final transient ba<K, V, M>.d b = new ba.d(ba.this, null);
    private final transient ba<K, V, M>.b c = new ba.b(ba.this, null);
    private final transient ba<K, V, M>.g d = new ba.g(ba.this, null);

    e()
    {
    }

    public Set<K> a()
    {
      return this.b;
    }

    public Set<Map.Entry<K, V>> b()
    {
      return this.c;
    }

    public Collection<V> c()
    {
      return this.d;
    }
  }

  private static class f<T>
    implements Iterator<T>
  {
    private final Iterator<T> a;

    public f(Iterator<T> paramIterator)
    {
      this.a = paramIterator;
    }

    public boolean hasNext()
    {
      return this.a.hasNext();
    }

    public T next()
    {
      return this.a.next();
    }

    public void remove()
    {
      throw new UnsupportedOperationException();
    }
  }

  private final class g extends ba.a<V>
  {
    private g()
    {
    }

    Collection<V> a()
    {
      return ba.a(ba.this).values();
    }

    public void clear()
    {
      ba.b(ba.this).lock();
      try
      {
        Map localMap = ba.this.a();
        localMap.values().clear();
        ba.this.b(localMap);
        return;
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }

    public boolean remove(Object paramObject)
    {
      ba.b(ba.this).lock();
      try
      {
        boolean bool1 = contains(paramObject);
        if (!bool1)
          return false;
        Map localMap = ba.this.a();
        try
        {
          boolean bool2 = localMap.values().remove(paramObject);
          ba.this.b(localMap);
          return bool2;
        }
        finally
        {
          ba.this.b(localMap);
        }
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }

    public boolean removeAll(Collection<?> paramCollection)
    {
      ba.b(ba.this).lock();
      try
      {
        Map localMap = ba.this.a();
        try
        {
          boolean bool = localMap.values().removeAll(paramCollection);
          ba.this.b(localMap);
          return bool;
        }
        finally
        {
          ba.this.b(localMap);
        }
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }

    public boolean retainAll(Collection<?> paramCollection)
    {
      ba.b(ba.this).lock();
      try
      {
        Map localMap = ba.this.a();
        try
        {
          boolean bool = localMap.values().retainAll(paramCollection);
          ba.this.b(localMap);
          return bool;
        }
        finally
        {
          ba.this.b(localMap);
        }
      }
      finally
      {
        ba.b(ba.this).unlock();
      }
    }
  }

  public static abstract class h<K, V>
  {
    abstract Set<K> a();

    abstract Set<Map.Entry<K, V>> b();

    abstract Collection<V> c();

    public static abstract enum a
    {
      static
      {
        a[] arrayOfa = new a[2];
        arrayOfa[0] = a;
        arrayOfa[1] = b;
      }

      abstract <K, V, M extends Map<K, V>> ba.h<K, V> a(ba<K, V, M> paramba);
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.chartboost.sdk.impl.ba
 * JD-Core Version:    0.6.2
 */